package cn.iocoder.yudao.module.book.dal.mysql.members;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.controller.app.classes.vo.AppClassMembersSaveReqVO;
import cn.iocoder.yudao.module.book.dal.dataobject.members.ClassMembersDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.members.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 班级成员 Mapper
 *
 * @author xi
 */
@Mapper
public interface ClassMembersMapper extends BaseMapperX<ClassMembersDO> {

    default PageResult<ClassMembersDO> selectPage(ClassMembersPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClassMembersDO>()
                .eqIfPresent(ClassMembersDO::getMembersId, reqVO.getMembersId())
                .eqIfPresent(ClassMembersDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ClassMembersDO::getClassesId, reqVO.getClassesId())
                .betweenIfPresent(ClassMembersDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClassMembersDO::getMembersId));
    }

    ClassMembersDO selectMember(@Param("membersId") Integer membersId);

    List<ClassMembersDO> selectClassesList(Long userId);
    
    /**
     * 直接SQL删除班级成员关系
     */
    void deleteMembersByClassId(@Param("classesId") Integer classesId);
}